package com.attendance.www.hr.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.attendance.www.hr.beans.CheckBean;
import com.attendance.www.hr.exception.ResultFaultException;
import com.attendance.www.hr.service.IAccessService;
import com.attendance.www.hr.service.ISchedulWeekService;
import com.zhangkongli.frame.core.ResultMap;

@Controller
@RequestMapping("/access")
public class AccessController {
	
	@Resource
	private IAccessService accessService;
	@Resource
	private ISchedulWeekService  schedulDayKeyAutoService;


	@RequestMapping(value = "/saveAttendaceAuto.do", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Object saveAttendaceAuto(HttpServletRequest request,@RequestBody CheckBean paramBean) {//CheckBean借用当参数的Bean
		
		if (paramBean.getThruDate()==null) {//选择的日期
			throw new ResultFaultException("0_00001");
		}
		if (accessService.saveAttendaceByDate(paramBean.getThruDate())) {
			return ResultMap.success();
		}
		throw new ResultFaultException("0_00032");
	}
	
	@RequestMapping(value = "/saveSchedulDayKeyAuto.do", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Object schedulDayKeyAuto(HttpServletRequest request) {//CheckBean借用当参数的Bean
		if (schedulDayKeyAutoService.saveSchedulDayKeyAuto()) {
			return ResultMap.success();
		}
		throw new ResultFaultException("0_00032");
	}
	
}
